
<template>
<el-form :data="tableData" ref="ruleForm" label-width="100px" class="demo-ruleForm"  style="width:40%;margin:0 auto">
  <el-form-item label="企业编号" prop="companyCode">
    <el-input v-model="tableData.companyCode" readonly></el-input>
  </el-form-item>
  <el-form-item label="企业名称" prop="companyName">
    <el-input v-model="tableData.companyName"></el-input>
  </el-form-item>
  <el-form-item label="证件类型" prop="idType">
    <el-select v-model="tableData.idType" placeholder="请输入证件类型">
      <el-option label="统一社会信用代码" value="a1"></el-option>
      <el-option label="组织机构代码" value="a2"></el-option>
      <el-option label="其他证件类型" value="a3"></el-option>
    </el-select>
  </el-form-item>
   <el-form-item label="证件号码" prop="idNumber">
    <el-input v-model="tableData.idNumber"></el-input>
  </el-form-item>
  <el-form-item label="企业成立日期" required>
    <el-col :span="11">
      <el-form-item prop="createDate">
        <el-date-picker type="date" placeholder="选择日期" v-model="tableData.createDate" style="width: 100%;" ></el-date-picker>
      </el-form-item>
    </el-col>
  </el-form-item>

  <el-form-item label="注册资本（万元）" prop="registerCapital">
    <el-input v-model="tableData.registerCapital"></el-input>
  </el-form-item>
  <el-form-item label="详细地址" prop="companyAddress">
    <el-input v-model="tableData.companyAddress"></el-input>
  </el-form-item>
  <el-form-item label="职工人数" prop="empNumber">
    <el-input v-model="tableData.empNumber"></el-input>
  </el-form-item>
  <el-form-item label="登记日期" prop="registerDate">
    <el-input v-model="tableData.registerDate" readonly></el-input>
  </el-form-item>
  <el-form-item label="更新日期" prop="updateDate">
    <el-input v-model="tableData.updateDate" readonly></el-input>
  </el-form-item>
  
 
  <el-form-item>
    <el-button type="primary" @click="submitForm('ruleForm')">保存修改</el-button>
     <el-button type="primary" @click="returnIndex">返回企业列表</el-button> 
    <el-button @click="resetForm('ruleForm')">重置</el-button>
  </el-form-item>
</el-form>
</template>

<script>

import {messagedetailToShow} from '@/api/message/index'

  export default {
    data() {
      return {
        ruleForm: {
          companyCode:'',
          companyName: '',
          idType: '',
          idNumber: '',
          createDate: '',
          registerCapital: '',
          companyAddress: '',
          empNumber: '',
          registerDate: '',
          updateDate: ''
        },
         tableDate:[],
        rules: {
          companyName: [
            { required: true, message: '请输入企业名称', trigger: 'blur' },
          ],
          idType: [
            { required: true, message: '请选择证件类型', trigger: 'change' }
          ],
          idNumber: [
            { required: true, message: '请输入证件号码', trigger: 'blur' }
          ],
          createDate: [
            { type: 'date', required: true, message: '请选择日期', trigger: 'blur' }
          ],
          registerCapital: [
            { required: true, message: '请输入注册资本（万元）', trigger: 'blur' }
          ],
          companyAddress: [
            { required: true, message: '请输入详细地址', trigger: 'blur' }
          ],
          empNumber: [
            { required: true, message: '请输入职工人数', trigger: 'blur' }
          ]
        }
      };
    },
    props:{
      companyCode :  {
        type: String,
        default: ""
      },
    },
    methods: {
       showmessagedetail(){
        messagedetailToShow(this.companyCode).then(res => {
           this.tableData = res
        }).catch((e) => {console.log(e )})
      },
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            alert('submit!');
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },deleteForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            alert('删除成功！');
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      },
       returnIndex(){
         this.$router.replace('/message')
       },
       
    },
    mounted(){
      this.showmessagedetail()
          }
  }
</script>



<style>
.el-input__inner{

  border:transprant
}
</style>